@svizzle/utils/string-[object-number]

Methods

(static) valuesMaxBy(key) → {function}

Source:
Since:
  • 0.1.0

Return a function expecting an object of objects and returning the max of values by the provided key. The same can be done by valuesMaxWith(_.getKey(key)) but here we avoid invoking a function for all the items.

Example
> maxByK1 = valuesMaxBy('k1')
> maxByK1({a: {k1: 1, k2: 20}, b: {k1: 3,  k2: 2}})
3
> maxByK1({a: {k1: 9, k2: 12}, b: {k1: 7,  k2: 2}})
7
Parameters:
Name Type Description
key string
Returns:
  • Object -> Number
Type
function

(static) valuesMinBy(key) → {function}

Source:
Since:
  • 0.1.0

Return a function expecting an object of objects and returning the min of values by the provided key. The same can be done by valuesMinWith(_.getKey(key)) but here we avoid invoking a function for all the items.

Example
> minByK1 = valuesMinBy('k1')
> minByK1({a: {k1: 1, k2: 20}, b: {k1: 3,  k2: 2}})
1
> minByK1({a: {k1: 9, k2: 12}, b: {k1: 7,  k2: 2}})
7
Parameters:
Name Type Description
key string
Returns:
  • Object -> Number
Type
function